<template>
  <div>
    <el-tabs type="border-card" @tab-click="tabClick">
      <el-tab-pane label="用户管理">
        <Table 
        v-on:CurrentChange="CurrentChange"
        :tableData="tableData" 
        :total="total" 
        :obj="obj"></Table>
      </el-tab-pane>
      <el-tab-pane label="配置管理">
        <Table></Table>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import Table from "./components/Table";
import { HTTPgetHouse } from "../../api/house";
export default {
  data() {
    return {
      activeIndex: "0",
      obj: {
        quyu: "",
        area: "",
        name: "",
        pageNum: 1,
        pageSize: 5,
      },
      total: 0,
      tableData: [],
    };
  },
  components: {
    Table,
  },
  created() {
    if (this.activeIndex === "0") {
      this.initDateHouse();
    }
  },
  methods: {
    tabClick(val) {
      this.activeIndex = val.index;
      if(val === '1') {
        this.initDateHouse1();
      }
    },
    async initDateHouse() {
      const res = await HTTPgetHouse({params: this.obj});
      if(res.status === 200 && res.data.code === 200) {
        this.tableData = res.data.data;
        this.total = res.data.nums;
      }
    },
    async initDateHouse1() {
      
    },
    CurrentChange(val) {
      this.obj.pageNum = val;
      this.initDateHouse();
    }
  },
};
</script>

<style>
</style>